#include "mainwindow.h"
#include "databasemanager.h"

#include <QApplication>
#include <QFile>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //设置应用程序的样式
    QFile file(":/style/style.qss");
    if (file.open(QFile::ReadOnly)) {
        QString styleSheet = file.readAll();
        a.setStyleSheet(styleSheet);
        file.close();
    }

    //打开数据库
    DataBaseManager &dbManager = DataBaseManager::getInstance();
    QString dbPath = QCoreApplication::applicationDirPath() + "/../sqllite/zyTechManSys.db";
    if (!dbManager.openDatabase(dbPath)) {
        qDebug() << "Failed to open database";
        return -1;
    }
    qDebug() << "Database path:" << dbManager.getDatabasePath();

    MainWindow w;
    w.show();
    return a.exec();
}
